import axios from "axios";

const config = {
  method: 'get',
  url: 'http://localhost:8010/admin/ts/al',
  responseType: 'stream'
};

const httpObject = {
	
	connection: param => {
		// var evtSource = new EventSource(config.url += "?con="+param.param);
		// evtSource.onmessage = function(e) {
		//     console.log(e.data);
		// 	if (e.data === '[end]') {
		// 		evtSource.close();
		// 	}
			
		// 	param.data(e.data);
		// };
		
		// evtSource.onerror = function(e) {
		//     console.error("EventSource failed:", e);
		//     evtSource.close();
		// };
		config.url = "http://localhost:8010/admin/ts/al?con="+param.param
		axios(config).then(response => {
			if (response.data) {
				let xxx = response.data; 
				//.split("</think>")[1];
				param.data(xxx);
			}
			
		});
	}
};

export default httpObject;
